home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / utility / pwg_key.zip / MOREINFO.TXT < prev    next >
Text File  |  1995-12-05  |  4KB  |  126 lines

  1. '*********************************************************************
  2. *
  3. '  Then I perform a Modulo 10 "Credit Card"-Style check on the Key
  4. 'Date: 1994-10-12,16:08
  5. From: BILL MASELLA
  6. To: DAVID PARKS
  7. Subject: Mod10 - Product Digit Add
  8. Flags:
  9.  
  10. DP=:-> Credit cards also use a modulus 10 check digit routine on them.
  11. If t
  12.   =:-> card number doesn't pass mod10 tthen you shouldn't allow it
  13. either.
  14.  
  15.  
  16. DP=:Back up.. I like what your saying, but I'm completely lost on what
  17.   =:Modulus 10 means..  I'm by now means a programmer..  Could you
  18. please
  19.   =:explain what the mod10 is?  I would be extremely interested to
  20. hear
  21.   =:about it.
  22.  
  23. The actual process goes something like this...
  24.  
  25. Multiply each digit of the card holder number by its appropriate
  26. number
  27. in the weight series ...2121 starting at the far right digit of the
  28. number.  Next take those products and add each of the digits together.
  29. If the sum is divisible by 10 then the number has the correct check
  30. digit on it.  If not the card is invalid....  Here is an example:
  31.  
  32. Card Number:        5  0  0  1  2  3  4  5  6  7  8  9  2  1  0  7
  33. Weight Series:      2  1  2  1  2  1  2  1  2  1  2  1  2  1  2  1
  34. -------------------------------------------------------------------
  35. Products:          10  0  0  1  4  3  8  5  12 7  16 9  4  1  0  7
  36. Add:               1+0+0 +0 +1 +4 +3 +8 +5+1+2+7+1+6+9 +4 +1 +0 +7 =
  37. 60
  38.  
  39.                    Is this sum EVENLY divisible by 10?  Yes! Card OK!
  40.  
  41. You need to pay close attention to starting the weighting with the
  42. RIGHT
  43. most digit first or it will not work.  On the shorter VISA numbers:
  44.  
  45.                          X  X  X  X     X  X  X     X  X  X     X  X
  46. X
  47.    Weighting would be:   1  2  1  2     1  2  1     2  1  2     1  2
  48. 1
  49.  
  50. Did this help?
  51.  
  52. You also know that the card numbers all have a certain length
  53. requirement and that they all generally have a unique first couple of
  54. digits which help you determine what card type you are looking at?
  55.  
  56. Visa all start with a 4   13 OR 16 digits long
  57. MasterCard with a 5       16 digits long
  58. Amex with a 37            15 digits long
  59. Discover with a 60        16 digits long
  60.  
  61. When we test them we usually run them through a mask first to see if
  62. it
  63. is XX digits long and starts with the appropriate number.  If not we
  64. never get to a check digit calculation.
  65.  
  66. ======================================================================
  67. ==
  68.  
  69. Date: 1994-10-14,09:13
  70. From: GREG HEWGILL
  71. To: DAVID PARKS
  72. Subject: Mod10 - Product Digit Add
  73. Flags: Read
  74.  
  75. DP>Wow!  That has helped me out a lot!  I have tried calling visa, MC,
  76. my
  77.   >credit service, and so on for an explanation like that!  Thank You
  78. very
  79.   >very much!!!  (Trying to figure out how to program that for a basic
  80.   >programmer like me will be a different story)  :)
  81.  
  82. Here's some code that will do that:
  83.  
  84. function JustDigits(cardnumber as string) as string
  85.   dim numbers as string
  86.   numbers = ""
  87.   dim i as integer
  88.   for i = 1 to len(cardnumber)
  89.     if mid(cardnumber, i, 1) >= "0" and mid(cardnumber, i, 1) <= "9"
  90. then
  91.       numbers = numbers + mid(cardnumber, i, 1)
  92.     end if
  93.   next
  94.   JustDigits = numbers
  95. end function
  96.  
  97. function ValidCardNumber(cardnumber as string) as integer
  98.   dim numbers as string
  99.   numbers = JustDigits(cardnumber)
  100.   dim sum as integer
  101.   sum = 0
  102.   dim m as integer
  103.   m = 2
  104.   dim i as integer
  105.   for i = len(numbers)-1 to 1 step -1
  106.     dim d as integer
  107.     d = val(mid(numbers, i, 1)) * m
  108.     if d >= 10 then
  109.       d = (d mod 10) + 1
  110.     end if
  111.     sum = sum + d
  112.     m = 3 - m
  113.   next
  114.   ValidCardNumber = (10 - (sum mod 10)) mod 10 = val(right(numbers,
  115. 1))
  116. end function
  117.  
  118. The ValidCardNumber function will return whether it thinks the card
  119. number is valid or not.  Hope this helps.
  120.  
  121. Greg
  122. MSI
  123.  
  124.  
  125. '******************************************************************
  126.